<style type='text/css'>
.form-control{padding:0;}
.col-md-55, .col-xs-1, .col-sm-1, .col-md-1, .col-lg-1, .col-xs-2, .col-sm-2, .col-md-2, .col-lg-2, .col-xs-3, .col-sm-3, .col-md-3, .col-lg-3, .col-xs-4, .col-sm-4, .col-md-4, .col-lg-4, .col-xs-5, .col-sm-5, .col-md-5, .col-lg-5, .col-xs-6, .col-sm-6, .col-md-6, .col-lg-6, .col-xs-7, .col-sm-7, .col-md-7, .col-lg-7, .col-xs-8, .col-sm-8, .col-md-8, .col-lg-8, .col-xs-9, .col-sm-9, .col-md-9, .col-lg-9, .col-xs-10, .col-sm-10, .col-md-10, .col-lg-10, .col-xs-11, .col-sm-11, .col-md-11, .col-lg-11, .col-xs-12, .col-sm-12, .col-md-12, .col-lg-12{padding:0;}
.col-lg-1, .col-lg-10, .col-lg-11, .col-lg-12, .col-lg-2, .col-lg-3, .col-lg-4, .col-lg-5, .col-lg-6, .col-lg-7, .col-lg-8, .col-lg-9, .col-md-1, .col-md-10, .col-md-11, .col-md-12, .col-md-2, .col-md-3, .col-md-4, .col-md-5, .col-md-6, .col-md-7, .col-md-8, .col-md-9, .col-sm-1, .col-sm-10, .col-sm-11, .col-sm-12, .col-sm-2, .col-sm-3, .col-sm-4, .col-sm-5, .col-sm-6, .col-sm-7, .col-sm-8, .col-sm-9, .col-xs-1, .col-xs-10, .col-xs-11, .col-xs-12, .col-xs-2, .col-xs-3, .col-xs-4, .col-xs-5, .col-xs-6, .col-xs-7, .col-xs-8, .col-xs-9{padding-left:2px;padding-right:0;}
.form-inline .form-control{border-radius:3px;padding-left:2px;}
#tablist tr td{color:black;}
.table-striped>tbody>tr:nth-of-type(odd){background:#fff}
.table-striped>tbody>tr:nth-of-type(even){background:#cae7ea}
.table-bordered>tbody>tr>td, .table-bordered>tbody>tr>th, .table-bordered>tfoot>tr>td, .table-bordered>tfoot>tr>th, .table-bordered>thead>tr>td, .table-bordered>thead>tr>th{
  border:1px solid #000;
}
#tablist tr th{background:#000;color:#fff;}
</style>


<form class="form-inline" method="get">
<p>今日可卖出金额：<span style="color: red">{$all_money.buyall}</span></p>

  <div class="form-group col-xs-1">
      <div class="col-xs-12">
          <input class="form-control" name="title" value="{$param.title|default=''}"
                 placeholder="产品名称">
      </div>
  </div>

    <div class="form-group col-xs-1">
        <div class="col-xs-12">
            <select class="form-control" name="peiduistatus" id="match_status">
                <option value="">全部</option>
                <option value="1" {if isset($param.peiduistatus) && $param.peiduistatus eq 1}selected{/if}>未匹配</option>
                <option value="2" {if isset($param.peiduistatus) && $param.peiduistatus eq 2}selected{/if}>已匹配</option>
            </select>
        </div>
    </div>

    <div class="form-group col-xs-2">
        <div class="col-xs-12">
            <span></span><input class="form-control" name="userinfo" value="{$param.userinfo|default=''}"
                   placeholder="购买人：用户名|手机号">
        </div>
    </div>
    <div class="form-group col-xs-1">
        <div class="col-xs-12">
            <select class="form-control" name="paystatus" id="paystatus">
                <option value="">全部</option>
                <option value="0" {if isset($param.paystatus) && $param.paystatus === '0'}selected{/if}>未付款</option>
                <option value="1" {if isset($param.paystatus) && $param.paystatus eq 1}selected{/if}>已付款</option>
                <option value="2" {if isset($param.paystatus) && $param.paystatus eq 2}selected{/if}>已完成</option>
            </select>
        </div>
    </div>

    <div class="form-group col-xs-1">
        <div class="col-xs-12">
            <select class="form-control" name="zhiding" id="zhiding">
                <option value="">全部指定</option>
                <option value="1" {if isset($param.zhiding) && $param.zhiding eq 1}selected{/if}>未指定</option>
                <option value="2" {if isset($param.zhiding) && $param.zhiding eq 2}selected{/if}>已指定</option>
            </select>
        </div>
    </div>

    <div class="form-group col-xs-1">
        <div class="col-xs-12">
            <select class="form-control" name="good_id" id="good_id">
                <option value=''   {if $good_id== 0}selected{/if} >全部产品</option>
                {foreach $good_list as $g}
                <option value='{$g.id}'   {if $good_id== $g['id']}selected{/if} >{$g.title}</option>
                {/foreach}
            </select>
        </div>
    </div>

    <div class="form-group col-xs-2">
        <div class="col-xs-12">
            <button type="submit" class="btn btn-success">
                筛选
            </button>
        </div>
    </div>
</form>

<hr>

<table class="table table-striped table-bordered" id="tablist">
    <thead>
    <tr>
      <th>编号ID</th>
      <th>购买人</th>
      <th>产品信息</th>
      <th>合约收益</th>
      <th>本次消费</th>
      <th>收益详情</th>
      <th>配对状态</th>
      <th>购买时间</th>
      <th>配对人</th>
      <th>配对订单id</th>
      <th>支付信息</th>
      <th>可卖出时间</th>
      <th>操作</th>
    </tr>
    </thead>
    <tbody>
    {volist name="list" id="item"}
    <tr>
        <td>
          <p>{$item.id}</p>
        </td>
        <td>
            <p><label class="label label-danger">账号：{$item.b_username}</label></p>
            <p><label class="label label-success">手机号：{$item.b_selfphone}</label></p>
        </td>
        <td>
            <p><label class="label label-danger">产品id：{$item.productid}</label></p>
            <p><label class="label label-success">产品名称：{$item.title}</label></p>
        </td>
        <td>
            {$item.daynum}天/{$item.earnpercent}%
        </td>
        <td>
            {$item.price}
            {if $item.xs == 1}
            <a href="{:url('Order/xschange',['id'=>$item['id'],'xs'=>2])}" class="label label-danger" title='可售不可售,同时也是会员看见看不见' >不可售</a>
            {/if}
            {if $item.xs == 2}
            <a href="{:url('Order/xschange',['id'=>$item['id'],'xs'=>1])}" class="label label-info" title='可售不可售,同时也是会员看见看不见' >可售</a>
            {/if}
        </td>
        <td>
            <p><label class="label label-danger">预计收益：{$item.dayaddprice}</label></p>
            <p><label class="label label-success">预计卖出可得：{$item.basicprice}</label></p>
        </td>
        <td>
            {if $item.peiduistatus eq 1}
            <p><label class="label label-danger">未配对</label></p>
            {else}
            <p><label class="label label-success">已配对</label></p>
            {/if}

            {if $item.applyid gt 0}
              <p>
                  <label class="label label-primary">{$item.applyid|getapplyinfo}</label>
              </p>
            {/if}

        </td>
        <td>
            {:date("Y-m-d H:i:s", $item.ctime)}
        </td>
        <td>
            {if !empty($item.m_username)}
            <p><label class="label label-danger">账号：{$item.m_username}</label></p>
            <p><label class="label label-success">手机号：{$item.m_selfphone}</label></p>
            {/if}
        </td>
        <td>
            {if $item.match_oid eq 0}

            {else}
            {$item.match_oid}
            {/if}
        </td>
        <td>
            {if $item.paystatus eq 0}
            <p><label class="label label-danger">未支付</label></p>
            {elseif $item.paystatus eq 1}
            <p><label class="label label-success">已支付</label></p>
            {elseif $item.paystatus eq 2}
            <p><label class="label label-success">已完成</label></p>
            {/if}
        </td>
        <td>
            {:date("Y-m-d H:i:s", $item.cansaletime)}
        </td>
        <td>
            <div class="btn-group">
                <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                    操作
                    <span class="caret"></span>
                </button>
                <ul class="dropdown-menu">
                    <li>
                        <a href="javascript:void(0)" onclick="modal('{:url(\'orderInfo\',array(\'id\'=>$item[\'id\']))}', '订单详情', '80%', '80%')">
                            订单详情
                        </a>
                    </li>

                    {if $item.paystatus neq 2 && $item.peiduistatus eq 2}
                    <li>
                        <a href="javascript:void(0)" onclick="cancelMatch('{$item.id}')">
                            订单取消配对
                        </a>
                    </li>
                    {/if}


                    <li role="separator" class="divider"></li>
                </ul>
            </div>
        </td>

    </tr>
    {/volist}
    </tbody>
</table>

<div class="row">
    <div class="col-xs-12" style="text-align: right;">
        {$list->render()}
    </div>
</div>

<script src="__PUBLIC__/vendors/select2/js/select2.min.js"></script>
<script type="application/javascript">
    function cancelMatch(id){
        layer.confirm("确定取消此订单？", function () {
            $.post("{:url('cancelMatch')}", {id:id}, function (res) {
                if(res.code == 0){
                    layer.msg(res.msg);
                    setTimeout(function () {
                        location.reload();
                    }, 666);
                }else{
                    layer.alert(res.msg);
                }
            });
        });


    }


    $(function () {
        /*修改标题*/
        var title="{$templateTitle}";
        $(".dakq-nav-title").text(title);
        //获取分类
        $("#match_status").select2({
            placeholder: "配对状态",
            allowClear: true
        });
        $("#paystatus").select2({
            placeholder: "支付状态",
            allowClear: true
        });
        $("#export").click(function () {
            let url = location.href;
            $("form").attr("action", "{:url('order_export')}");
            $("form").submit();
            $("form").attr("action", url);
        });
    });
</script>
